package com.yaolong.api.modules.resident.service.impl;

import com.yaolong.api.modules.resident.entity.OpmsFixResident;
import com.yaolong.api.modules.resident.dao.OpmsFixResidentDao;
import com.yaolong.api.modules.resident.service.OpmsFixResidentService;
import com.yaolong.commons.base2.BaseServiceImpl;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.util.ObjectUtils;
import java.util.List;

/**
 * <p>
 * 常住居民表 服务实现类
 * </p>
 *
 * @author yaolonga
 * @since 2023-02-19
 * @version v1.0.0
 */
@Service
public class OpmsFixResidentServiceImpl extends BaseServiceImpl<OpmsFixResidentDao, OpmsFixResident> implements OpmsFixResidentService {
   @Override
   public IPage<OpmsFixResident> page(int current, int size, OpmsFixResident domain) {
     IPage<OpmsFixResident> page = new Page<>(current, size);
     return lambdaQuery()
            .eq(!ObjectUtils.isEmpty(domain.getHkType()), OpmsFixResident::getHkType, domain.getHkType())
            .like(!ObjectUtils.isEmpty(domain.getName()), OpmsFixResident::getName, domain.getName())
            .like(!ObjectUtils.isEmpty(domain.getFormerName()), OpmsFixResident::getFormerName, domain.getFormerName())
            .like(!ObjectUtils.isEmpty(domain.getIdCard()), OpmsFixResident::getIdCard, domain.getIdCard())
            .eq(!ObjectUtils.isEmpty(domain.getBirthPlace()), OpmsFixResident::getBirthPlace, domain.getBirthPlace())
            .eq(!ObjectUtils.isEmpty(domain.getHjAddr()), OpmsFixResident::getHjAddr, domain.getHjAddr())
            .eq(!ObjectUtils.isEmpty(domain.getMaritalStatus()), OpmsFixResident::getMaritalStatus, domain.getMaritalStatus())
            .page(page);
   }

    @Override
    public List<OpmsFixResident> list( OpmsFixResident domain) {
      return lambdaQuery()
            .eq(!ObjectUtils.isEmpty(domain.getHkType()), OpmsFixResident::getHkType, domain.getHkType())
            .like(!ObjectUtils.isEmpty(domain.getName()), OpmsFixResident::getName, domain.getName())
            .like(!ObjectUtils.isEmpty(domain.getFormerName()), OpmsFixResident::getFormerName, domain.getFormerName())
            .like(!ObjectUtils.isEmpty(domain.getIdCard()), OpmsFixResident::getIdCard, domain.getIdCard())
            .eq(!ObjectUtils.isEmpty(domain.getBirthPlace()), OpmsFixResident::getBirthPlace, domain.getBirthPlace())
            .eq(!ObjectUtils.isEmpty(domain.getHjAddr()), OpmsFixResident::getHjAddr, domain.getHjAddr())
            .eq(!ObjectUtils.isEmpty(domain.getMaritalStatus()), OpmsFixResident::getMaritalStatus, domain.getMaritalStatus())
            .list();
    }


}
